<?php namespace Admin\Controller; 
use Hdphp\Controller\Controller;
//网站配置控制器
class WebSetController extends CommonController{
	public function index(){
		$model = new \Admin\Model\WebSet;
		if(IS_POST){
			//[CODE_LEN] => 40
			//UPDATE webset SET value=40 WHERE name='CODE_LEN'; 
			foreach (Q('post.') as $k => $v) {
		 		$model->where("name='{$k}'")->save(array('value'=>$v));
			}
			//写入配置项文件
			file_put_contents('./Config/webset.php', "<?php return " . var_export(Q('post.'),true) . ";");
			View::success('更改成功');
		}
		$data = $model->get();
		View::with('data',$data);
		View::make();
	}
}